Git & GitHub
Git is a distributed version control system used to track changes in source code, maintain project history, create branches, collaborate with other developers, and safely manage different versions of a software project. Git allows developers to work locally while maintaining a complete history of project changes.
GitHub is a cloud-based platform built around Git that provides remote repositories and collaboration features such as pull requests, code reviews, issues, project discussions, and repository management. Git and GitHub are commonly used together in modern software development and automation projects. :contentReference[oaicite:0]{index=0}
For Selenium automation engineers, Git and GitHub are especially important because automation frameworks usually contain many test classes, Page Object classes, configuration files, test data files, utilities, reports, and CI/CD configuration. Version control makes it easier to track, review, share, and restore these project changes.
Course Resource: Selenium Training | Register for Course Demo
1. What is Git?
Git is a distributed version control system that records changes made to files over time. It allows developers to create snapshots of a project, compare changes, restore previous versions, work on separate branches, and combine work from multiple developers.
Because Git is distributed, developers normally have a complete local repository containing the project's history, branches, and files rather than depending entirely on a central server. :contentReference[oaicite:1]{index=1}
Example
Project
|
+-- LoginTest.java
+-- SearchTest.java
+-- LoginPage.java
+-- ConfigReader.java
|
v
Git Repository
|
+-- Commit 1
+-- Commit 2
+-- Commit 3
+-- Commit 4
2. What is GitHub?
GitHub is a hosting and collaboration platform for Git repositories. A local Git repository can be connected to a remote repository on GitHub so developers can publish commits, collaborate with teammates, review changes, and manage project work.
GitHub supports collaboration through repositories, branches, pull requests, code reviews, issues, and other development tools. :contentReference[oaicite:2]{index=2}
3. Git vs GitHub
| Git | GitHub |
| Version control system | Platform for hosting and collaboration |
| Runs locally | Primarily provides remote/cloud collaboration |
| Tracks project history | Hosts Git repositories |
| Uses commands such as git commit | Provides repository and collaboration interfaces |
| Can work without GitHub | Uses Git as its core version-control system |
| Manages local branches and commits | Supports remote repositories, pull requests, reviews, and collaboration |
4. Why Git is Important for Selenium Testers
Git is an important skill for Selenium automation engineers because automation projects are continuously modified as new test cases, page objects, utilities, browsers, environments, and reporting features are added.
- Tracks changes in automation scripts.
- Maintains project history.
- Allows developers and testers to work on separate branches.
- Helps recover previous working versions.
- Supports collaboration between automation engineers.
- Works well with CI/CD systems.
- Makes code review possible through GitHub workflows.
- Helps maintain automation frameworks in teams.
- Supports release and deployment workflows.
- Provides a structured way to manage source code.
5. Version Control System
A Version Control System (VCS) records changes to files so that previous versions can be inspected or restored. Instead of manually creating folders such as project-final, project-final-new, and project-final-latest, Git maintains a structured history of changes.
Without Version Control
Project_Final
Project_Final_New
Project_Final_New_Updated
Project_Final_Updated_2
Project_Final_Final
With Git
Repository
|
+-- Commit A
+-- Commit B
+-- Commit C
+-- Commit D
6. Distributed Version Control
Git is distributed, meaning each cloned repository contains the files and repository history needed for local version-control operations. Developers can create commits, branches, and inspect history locally, then synchronize with a remote repository when required.
Developer A
|
v
Local Git Repository
|
+--------------------+
|
v
GitHub Repository
^
|
+--------------------+
|
v
Developer B
Local Git Repository
7. Git Repository
A Git repository is a project directory tracked by Git. It contains the project files and Git's internal repository information, including commit history and branch information.
A repository can exist locally on a developer's computer and can also be associated with a remote repository such as GitHub.
8. Working Directory, Staging Area and Repository
One of the most important concepts in Git is understanding the movement of changes between the working directory, staging area, and repository.
Working Directory
|
| git add
v
Staging Area
|
| git commit
v
Local Repository
|
| git push
v
Remote Repository
Working Directory
The working directory contains the files currently being edited.
Staging Area
The staging area contains changes selected for the next commit.
Local Repository
The local repository contains committed project history.
Remote Repository
The remote repository is a repository hosted on a remote service such as GitHub.
9. Installing Git
Git must be installed on the computer before Git commands can be used from the command line. Installation steps depend on the operating system.
After installation, verify Git using:
git --version
Example output:
git version 2.x.x
10. Configuring Git Username
Git uses a configured username to associate commits with an author identity.
git config --global user.name "Your Name"
To verify the configuration:
git config --global user.name
11. Configuring Git Email
An email address can also be configured for Git commit identity.
git config --global user.email "[email protected]"
To verify:
git config --global user.email
Git's tutorial documentation also recommends configuring a name and email before performing normal Git operations. :contentReference[oaicite:3]{index=3}
12. Checking Git Configuration
To display Git configuration values:
git config --list
You can also inspect a specific value:
git config --global user.name
git config --global user.email
13. git init
The git init command initializes a new Git repository in an existing project directory.
git init
After initialization, Git creates its internal repository data under the .git directory.
Typical Flow
Existing Project
|
| git init
v
Git Repository
14. Creating a New Project Repository
mkdir selenium-project
cd selenium-project
git init
Now the directory is ready to be managed by Git.
15. git status
The git status command shows the current state of the working directory and staging area.
git status
It can show information such as untracked files, modified files, and staged changes. GitHub's documentation identifies git status as a basic command for viewing changes as untracked, modified, or staged. :contentReference[oaicite:4]{index=4}
16. Creating a File
Suppose a Selenium project contains the following file:
LoginTest.java
After creating or modifying the file, run:
git status
Git may identify the file as untracked if it has not yet been added to version control.
17. git add
The git add command stages changes for the next commit.
git add LoginTest.java
To stage all suitable changes in the current directory:
git add .
Staging allows the developer to select exactly which changes should become part of the next snapshot. :contentReference[oaicite:5]{index=5}
18. Staging Area
The staging area is an intermediate area between the working directory and the repository.
File Modified
|
v
git add
|
v
Staging Area
|
v
git commit
|
v
Repository
This separation gives developers control over which changes are included in a commit.
19. git commit
The git commit command creates a snapshot of staged changes in the local repository.
git commit -m "Add login automation test"
A commit should have a meaningful message describing the change.
Good Commit Messages
git commit -m "Add login page object"
git commit -m "Add checkout test cases"
git commit -m "Fix login locator"
git commit -m "Update browser configuration"
A commit acts as a saved snapshot in the project's history. :contentReference[oaicite:6]{index=6}
20. Git Commit Workflow
Edit Files
|
v
git status
|
v
git add
|
v
git commit
|
v
Local History
21. git log
The git log command displays commit history.
git log
A compact version can be displayed using:
git log --oneline
Example
a31f2c1 Add checkout automation
b52e8d2 Fix login locator
c73a912 Add search page
d84f021 Initial framework
22. git diff
The git diff command can be used to inspect changes that have not yet been staged.
git diff
This is useful for reviewing code before staging or committing it.
23. Git Branch
A branch is an independent line of development. Branches allow developers to work on features or fixes without directly changing another branch.
main
|
+-- feature-login
|
+-- feature-search
|
+-- bugfix-checkout
Branches are lightweight in Git and are commonly used to isolate work before changes are merged into a main development line. :contentReference[oaicite:7]{index=7}
24. git branch
To list local branches:
git branch
To create a new branch:
git branch login-feature
25. Switching Branches
Modern Git provides the git switch command for changing branches.
git switch login-feature
A branch can also be created and switched to in one command:
git switch -c login-feature
26. Branch Workflow for Selenium Automation
main
|
+-- login-feature
| |
| +-- LoginTest.java
| +-- LoginPage.java
|
+-- search-feature
|
+-- SearchTest.java
+-- SearchPage.java
This allows different automation features to be developed independently.
27. Main Branch
The primary branch is commonly named main. It is often used as the stable integration branch of a project.
A common workflow is to create feature branches from main, develop and test changes there, and then propose those changes for integration into main.
28. Git Merge
The git merge command combines changes from one branch into another.
git switch main
git merge login-feature
Git's documentation describes merge as a command for combining lines of development, such as bringing work from a feature branch into another branch. :contentReference[oaicite:8]{index=8}
29. Merge Conflict
A merge conflict occurs when Git cannot automatically determine how to combine changes from different lines of development.
Developer A
|
+-- LoginTest.java
|
v
Feature Branch
Developer B
|
+-- LoginTest.java
|
v
Main Branch
|
v
Merge
|
v
Possible Conflict
When a conflict occurs, the developer must inspect the conflicting file, decide which changes should remain, remove the conflict markers, and create an appropriate commit.
30. Conflict Markers
A conflicted file may contain markers similar to:
<<<<<<< HEAD
Current branch changes
=======
Incoming branch changes
>>>>>>> feature-login
The developer resolves the content and removes the conflict markers before staging the resolved file.
31. Remote Repository
A remote repository is another copy of a Git repository accessible through a remote URL. A GitHub repository is a common remote repository used for team collaboration.
A remote URL can use HTTPS or SSH, and Git commonly names the default remote origin. :contentReference[oaicite:9]{index=9}
32. git remote
To view configured remotes:
git remote -v
Example:
origin https://github.com/user/selenium-project.git (fetch)
origin https://github.com/user/selenium-project.git (push)
33. Connecting Local Repository to GitHub
After creating a GitHub repository, connect the local Git repository to it using:
git remote add origin https://github.com/YOUR-USERNAME/YOUR-REPOSITORY-NAME.git
Then verify:
git remote -v
GitHub documents git remote add origin as a way to associate a remote URL with the name origin. :contentReference[oaicite:10]{index=10}
34. git clone
The git clone command creates a local copy of an existing remote repository.
git clone https://github.com/user/selenium-project.git
The cloned repository contains the project files and Git history available from the remote repository. :contentReference[oaicite:11]{index=11}
35. Clone Workflow
GitHub Repository
|
| git clone
v
Local Repository
|
v
Working Directory
36. git push
The git push command sends local commits to a remote repository.
git push
For a newly created branch, you may establish its upstream remote branch using:
git push -u origin feature-login
GitHub documents git push as the command used to update a remote repository with commits made locally. :contentReference[oaicite:12]{index=12}
37. git pull
The git pull command obtains changes from the corresponding remote branch and integrates them into the current local line of development.
git pull
It is commonly used before starting new work when teammates may have published updates to the remote repository.
38. git fetch
The git fetch command retrieves information and updates from a remote repository without directly integrating those changes into the current working branch.
git fetch origin
This can be useful when you want to inspect remote changes before deciding how to integrate them.
39. Pull vs Fetch
| git fetch | git pull |
| Downloads remote updates | Downloads and integrates remote updates |
| Does not directly update the current branch | Updates the current local branch |
| Useful for inspecting remote changes | Useful for synchronizing local work |
40. GitHub Repository
A GitHub repository is a remotely hosted project repository. It can contain source code, documentation, configuration files, test automation scripts, issues, and other project resources.
A Selenium automation repository may contain:
selenium-framework/
|
|-- src/
| |-- test/
| |-- main/
|
|-- pom.xml
|-- testng.xml
|-- README.md
|-- .gitignore
|-- config.properties
41. README.md
A README.md file documents the project. It commonly explains what the project does, how to install it, how to execute tests, required tools, project structure, and other useful information.
Example
# Selenium Automation Framework
## Overview
Selenium TestNG automation framework.
## Requirements
- Java
- Maven
- Selenium
- TestNG
## Execution
mvn test
42. .gitignore
The .gitignore file specifies files and directories that Git should ignore.
A Selenium project may ignore generated reports, compiled files, IDE metadata, temporary files, and local configuration containing sensitive information.
Example
target/
*.log
.idea/
.classpath
.project
test-output/
*.tmp
Using .gitignore helps prevent unnecessary generated files from entering the repository.
43. GitHub Commit History
GitHub displays commits that have been pushed to the remote repository. Commit history helps developers understand how a project changed over time.
Commit History
Add checkout tests
|
Fix payment locator
|
Add payment page
|
Add login test
|
Initial framework
44. GitHub Branches
GitHub supports remote branches that correspond to branches in Git repositories. Teams can use branches to isolate features, fixes, experiments, or release work.
main
|
+-- feature-login
|
+-- feature-search
|
+-- bugfix-payment
|
+-- release-v1
45. Pull Request
A Pull Request (PR) is a GitHub collaboration mechanism used to propose changes from one branch to another. Team members can review the proposed changes, discuss them, and merge them when the project's workflow requirements are satisfied. :contentReference[oaicite:13]{index=13}
feature-login
|
| Pull Request
v
main
46. Pull Request Workflow
Create Feature Branch
|
v
Write Code
|
v
Run Selenium Tests
|
v
git add
|
v
git commit
|
v
git push
|
v
Create Pull Request
|
v
Code Review
|
v
Merge
47. Code Review
Code review is the process of examining proposed code changes before they are integrated into another branch.
In a Selenium project, reviewers may check:
- Locator quality.
- Page Object design.
- Test readability.
- Duplicate code.
- Exception handling.
- Wait strategies.
- Test data handling.
- Security issues.
- Framework structure.
- Potential flaky-test problems.
48. GitHub Issues
GitHub Issues can be used to track bugs, tasks, enhancements, and other project discussions.
Example Selenium Issues
- Login test failing in Firefox.
- Checkout locator changed.
- Add data-driven search tests.
- Improve WebDriver factory.
- Add HTML test reporting.
49. Git Tags
Git tags can identify specific points in repository history, commonly for releases or important versions.
git tag v1.0
git tag v1.1
Tags can help teams identify stable framework or application versions.
50. Git Stash
The git stash command temporarily saves local modifications so you can work on another branch or perform another Git operation without committing unfinished work.
git stash
To restore the most recently stashed changes:
git stash pop
Example Scenario
Working on Login Feature
|
v
Urgent Bug Fix Required
|
v
git stash
|
v
Switch to Bugfix Branch
|
v
Fix Bug
|
v
Return to Login Feature
|
v
git stash pop
51. Git Reset
The git reset command can move the current branch reference and, depending on the mode, alter staging and working-tree state. It should be used carefully because some forms can discard work.
Example
git reset HEAD~1
Before using reset on shared branches, understand exactly which history and working-tree changes the selected mode will produce.
52. Git Revert
The git revert command creates a new commit that reverses the effect of an earlier commit.
git revert <commit-id>
Revert is often useful when a change has already been shared with others and you want to undo its effect without rewriting the existing shared history.
53. Reset vs Revert
| Reset | Revert |
| Moves branch history | Creates a new reversing commit |
| Can change commit history | Preserves existing commits |
| Use carefully on shared branches | Often suitable for undoing shared changes |
54. Git Checkout
git checkout is an older, widely used Git command that can switch branches and perform other operations. Modern Git provides more specialized commands such as git switch for branch switching and git restore for restoring files.
git checkout feature-login
55. Git Restore
The git restore command can restore files to a previous state or remove changes from the working tree or staging area depending on how it is used.
git restore LoginTest.java
Always review the intended effect before restoring uncommitted work.
56. Git Remote Workflow
Local Working Directory
|
v
git add
|
v
git commit
|
v
Local Branch
|
v
git push
|
v
GitHub Remote Branch
57. Complete Basic Git Workflow
A common Git workflow for a new automation project is:
1. Create project
2. git init
3. Create files
4. git status
5. git add .
6. git commit -m "Initial framework"
7. Create GitHub repository
8. git remote add origin <REMOTE_URL>
9. git push -u origin main
58. Complete Selenium Git Workflow
Create Selenium Framework
|
v
git init
|
v
Create Tests
|
v
git status
|
v
git add .
|
v
git commit
|
v
Create Branch
|
v
Develop Feature
|
v
Run Selenium Tests
|
v
git push
|
v
Pull Request
|
v
Code Review
|
v
Merge
59. Git with Maven Selenium Project
A typical Selenium Maven project may contain:
selenium-framework/
|
|-- src/
| |-- main/
| | |-- java/
| | |-- pages/
| | |-- utilities/
| |
| |-- test/
| |-- java/
| |-- tests/
|
|-- pom.xml
|-- testng.xml
|-- README.md
|-- .gitignore
Git can track the source files and project configuration while generated output such as Maven's target/ directory can normally be excluded through .gitignore.
60. Git with Page Object Model
Git is especially useful when a Selenium framework uses Page Object Model because page classes, test classes, utilities, and configuration files are often developed independently.
Git Repository
|
+-- pages
| +-- LoginPage.java
| +-- SearchPage.java
|
+-- tests
| +-- LoginTest.java
| +-- SearchTest.java
|
+-- utilities
+-- DriverFactory.java
+-- ConfigReader.java
61. Git Branching Strategy for Automation
A simple automation team can use branches such as:
main
|
+-- feature/login-tests
+-- feature/search-tests
+-- feature/checkout-tests
+-- bugfix/login-locator
+-- feature/reporting
Each branch can contain focused changes before being reviewed and merged.
62. Git and Test Reports
Test reports generated by Selenium/TestNG should be handled carefully. Source code and framework configuration generally belong in version control, while generated report directories may be excluded depending on the team's reporting and CI/CD strategy.
Example .gitignore
target/
test-output/
reports/
*.log
Teams may choose a different strategy if reports are intentionally published or retained as build artifacts.
63. Git and Test Data
Test data can be maintained in CSV, JSON, Excel, database, or configuration files. Not every data file should automatically be committed to Git.
Credentials, tokens, private keys, and other secrets should not normally be stored as plain text in a public or shared source repository.
Safer Structure
Framework
|
+-- Source Code
|
+-- Non-sensitive Test Data
|
+-- Configuration Templates
|
+-- Secure Runtime Secrets
64. Git and CI/CD
Git repositories are commonly used as the source for CI/CD pipelines. A pipeline can detect repository changes, build the project, execute automated tests, and publish results.
Developer
|
v
git push
|
v
GitHub
|
v
CI/CD Pipeline
|
+-- Build
|
+-- Selenium Tests
|
+-- Test Reports
|
v
Build Result
65. GitHub Actions
GitHub Actions is a GitHub automation platform that can be used to build workflows around repository events. A Selenium project can use a workflow to install dependencies, execute Maven tests, and publish or retain test results according to the project's configuration.
Example Workflow Concept
Git Push
|
v
GitHub Actions
|
v
Checkout Repository
|
v
Setup Java
|
v
Run Maven Tests
|
v
Selenium Execution
|
v
Test Report
66. GitHub Actions Example for Maven
name: Selenium Tests
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Run Tests
run: mvn test
The exact workflow should be adjusted to the project's Java version, browser strategy, Selenium setup, test runner, and reporting requirements.
67. GitHub Fork
A fork is a separate repository copy under another GitHub account or organization. Forks are commonly used when contributing to repositories where direct write access is not available.
Original Repository
|
v
Fork
|
v
Personal Repository
|
v
Feature Branch
|
v
Pull Request
|
v
Original Repository
68. GitHub Collaboration Workflow
Repository
|
v
Clone
|
v
Create Branch
|
v
Modify Code
|
v
Commit
|
v
Push
|
v
Pull Request
|
v
Review
|
v
Merge
This branch-and-pull-request workflow is a common way to collaborate on GitHub projects. :contentReference[oaicite:14]{index=14}
69. GitHub Permissions
GitHub repositories can use access controls to determine who can view, modify, review, or manage project resources. Teams should grant only the access appropriate for the project's collaboration requirements.
For automation projects, repository permissions are important because test code may contain application URLs, configuration, test data, or internal implementation details.
70. GitHub Security Best Practices
- Do not commit passwords or API tokens.
- Do not commit private keys.
- Use appropriate repository visibility.
- Review code before merging.
- Use protected branch rules where appropriate.
- Keep dependencies updated.
- Use secret-management features for sensitive CI/CD values.
- Review accidentally committed sensitive files immediately.
- Use meaningful commit messages.
- Keep generated files out of source control when appropriate.
71. Git Tags and Releases
Tags can identify specific versions of a Selenium framework or project.
git tag v1.0.0
git push origin v1.0.0
For example:
v1.0.0
|
+-- Initial Selenium Framework
v1.1.0
|
+-- Added Data Providers
v1.2.0
|
+-- Added Reporting
72. Git Log and Project Debugging
Git history can help identify when a Selenium test, locator, configuration, or utility changed.
git log --oneline -- LoginTest.java
This can help an engineer investigate whether a failure appeared after a particular code change.
73. Comparing Changes
Git provides several ways to compare current and historical versions of files.
git diff
git diff --staged
git diff HEAD
git diff main..feature-login
These commands can help review modifications before committing or merging.
74. Common Git Mistakes
- Committing generated files unnecessarily.
- Committing passwords or API tokens.
- Using unclear commit messages.
- Working directly on the main branch when a feature branch is expected.
- Forgetting to pull or fetch remote changes.
- Ignoring merge conflicts instead of resolving them carefully.
- Using force push without understanding its impact.
- Committing large unnecessary files.
- Not reviewing changes before committing.
- Ignoring the repository's contribution guidelines.
75. Git Best Practices
- Use meaningful branch names.
- Make focused commits.
- Write descriptive commit messages.
- Review changes before committing.
- Keep branches focused on a logical task.
- Pull or fetch remote updates regularly.
- Resolve conflicts carefully.
- Keep sensitive information outside source control.
- Maintain a useful README file.
- Use a suitable .gitignore file.
- Review pull requests before merging.
- Run automated tests before creating or merging important changes.
76. Useful Git Commands
| Command | Purpose |
| git --version | Displays Git version |
| git config | Configures Git settings |
| git init | Initializes repository |
| git clone | Copies a remote repository locally |
| git status | Shows repository status |
| git add | Stages changes |
| git commit | Creates a commit |
| git log | Shows commit history |
| git diff | Shows changes |
| git branch | Lists or manages branches |
| git switch | Switches branches |
| git merge | Combines branches |
| git remote | Manages remote repositories |
| git fetch | Retrieves remote updates |
| git pull | Retrieves and integrates remote changes |
| git push | Publishes local commits to remote |
| git stash | Temporarily stores uncommitted changes |
| git revert | Creates a commit that reverses another commit |
| git tag | Creates version tags |
These commands cover the core workflow documented by GitHub for working with Git repositories. :contentReference[oaicite:15]{index=15}
77. Practical Selenium Project Workflow
Suppose a QA automation engineer is developing a Selenium login feature.
Step 1:
Clone Repository
Step 2:
Create Branch
feature/login
Step 3:
Create LoginPage.java
Step 4:
Create LoginTest.java
Step 5:
Run Selenium Tests
Step 6:
git status
Step 7:
git add .
Step 8:
git commit -m "Add login automation"
Step 9:
git push -u origin feature/login
Step 10:
Create Pull Request
Step 11:
Code Review
Step 12:
Merge into main
78. Complete Git & GitHub Project Structure
selenium-automation/
|
|-- src/
| |
| |-- main/
| | |
| | +-- java/
| | |
| | +-- pages/
| | | +-- LoginPage.java
| | | +-- SearchPage.java
| | |
| | +-- utilities/
| | +-- DriverFactory.java
| | +-- ConfigReader.java
| |
| +-- test/
| |
| +-- java/
| |
| +-- tests/
| +-- LoginTest.java
| +-- SearchTest.java
|
|-- pom.xml
|-- testng.xml
|-- README.md
|-- .gitignore
79. Real-World Git & GitHub Architecture
GitHub
|
Remote Repository
|
+-----+-----+
| |
main branches
| |
| feature branches
| |
+-----+-----+
|
Pull Request
|
Code Review
|
Merge
|
main branch
|
CI/CD
|
Selenium Automation
|
Test Reports
80. Git Workflow for a Selenium Team
| Stage | Typical Activity |
| 1 | Clone or update repository |
| 2 | Create feature or bug-fix branch |
| 3 | Develop Selenium automation |
| 4 | Run tests locally |
| 5 | Review Git changes |
| 6 | Commit changes |
| 7 | Push branch |
| 8 | Create pull request |
| 9 | Review and address feedback |
| 10 | Merge after project checks are satisfied |
| 11 | CI/CD executes automated validation |
81. Interview Questions on Git & GitHub
1. What is Git?
Git is a distributed version control system used to track changes and maintain project history.
2. What is GitHub?
GitHub is a platform for hosting Git repositories and providing collaboration features around Git.
3. What is the difference between Git and GitHub?
Git is the version control system, while GitHub is a platform that hosts Git repositories and provides collaboration capabilities.
4. What is a Git repository?
A Git repository is a project directory managed by Git that contains files and version-control history.
5. What does git init do?
It initializes a Git repository in a directory.
6. What does git clone do?
It creates a local copy of an existing remote repository.
7. What does git add do?
It stages changes for the next commit.
8. What does git commit do?
It records staged changes as a snapshot in the local repository history.
9. What does git push do?
It publishes local commits to a remote repository.
10. What does git pull do?
It obtains changes from a remote repository and integrates them into the current local branch.
11. What is a branch?
A branch is an independent line of development used to isolate changes.
12. What is a merge?
Merge combines changes from different branches.
13. What is a merge conflict?
A merge conflict occurs when Git cannot automatically combine conflicting changes.
14. What is a pull request?
A pull request proposes changes from one branch to another for review and integration.
15. What is .gitignore?
.gitignore specifies files and directories that Git should normally ignore.
16. What is git status?
It displays the state of the working directory and staging area.
17. What is git log?
It displays commit history.
18. What is git stash?
It temporarily stores uncommitted changes so work can be switched without committing unfinished changes.
19. Why is Git useful for Selenium?
Git helps Selenium teams manage automation code, framework changes, branches, collaboration, history, and CI/CD integration.
20. Why should secrets not be committed?
Secrets such as passwords, tokens, and private keys can expose sensitive access if they are stored in source control.
82. Practical Exercises
- Install Git and verify it with
git --version.
- Configure Git username and email.
- Create a new Selenium project.
- Initialize the project using
git init.
- Create a
.gitignore file.
- Create a README file.
- Stage the project using
git add.
- Create an initial commit.
- Create a GitHub repository.
- Connect the local repository to GitHub.
- Push the main branch.
- Create a feature branch.
- Add a Selenium login test.
- Commit and push the feature branch.
- Create a pull request.
- Review the changes.
- Merge the feature after the project's required checks.
- Pull the latest main branch.
- Create another feature branch.
- Practice resolving a controlled merge conflict.
83. Learning Roadmap for Git & GitHub
- Understand version control.
- Learn Git vs GitHub.
- Install Git.
- Configure Git identity.
- Understand repositories.
- Learn working directory and staging area.
- Learn
git init.
- Learn
git status.
- Learn
git add.
- Learn
git commit.
- Learn
git log and git diff.
- Learn branches.
- Learn merge and conflict resolution.
- Learn remote repositories.
- Learn clone, fetch, pull, and push.
- Create and manage GitHub repositories.
- Learn pull requests and code review.
- Use Git with Selenium and Maven.
- Integrate GitHub with CI/CD.
- Practice complete team workflows.
84. Quick Revision Table
| Concept | Meaning |
| Git | Distributed version control system |
| GitHub | Platform for hosting and collaborating on Git repositories |
| Repository | Project managed by Git |
| Working Directory | Current project files being edited |
| Staging Area | Changes selected for the next commit |
| Commit | Snapshot of staged changes |
| Branch | Independent line of development |
| Merge | Combines branches |
| Remote | Remote repository location |
| Origin | Common name for the default remote |
| Clone | Copies a remote repository locally |
| Push | Sends local commits to remote |
| Pull | Gets and integrates remote changes |
| Fetch | Gets remote updates without directly integrating them into the current branch |
| Pull Request | Proposal to integrate branch changes |
| .gitignore | Specifies files Git should ignore |
| Tag | Identifies a specific point in repository history |
85. Summary
Git is a distributed version control system that helps developers and testers track project changes, maintain history, create branches, compare modifications, merge work, and restore previous versions when required.
GitHub provides remote repository hosting and collaboration capabilities around Git. It supports workflows involving branches, pull requests, code review, issues, and repository management. :contentReference[oaicite:16]{index=16}
For Selenium automation engineers, Git and GitHub are essential tools for managing automation frameworks, Page Object classes, test cases, utilities, configuration files, test data, Maven projects, and CI/CD workflows.
A typical Selenium Git workflow is:
Clone / Init
|
v
Create Branch
|
v
Write Selenium Code
|
v
Run Tests
|
v
git add
|
v
git commit
|
v
git push
|
v
Pull Request
|
v
Code Review
|
v
Merge
|
v
CI/CD
|
v
Test Reports
86. Course Resources
Learn more about Selenium automation and related testing concepts:
Final Takeaway: Git manages version history and collaboration at the source-control level, while GitHub provides a platform for hosting repositories and collaborating around them. For a Selenium automation engineer, knowing Git, branches, commits, pull requests, conflict resolution, and GitHub workflows is an important part of working effectively in a professional automation team.